package com.itdct.mto.core.service;

import com.itdct.mto.core.base.BaseService;
import com.itdct.mto.core.context.Context;
import com.itdct.mto.core.manager.ResultPrintManager;
import com.itdct.mto.core.manager.base.BaseDataTransferManager;
import com.itdct.mto.core.manager.base.BaseTableConvertManager;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import lombok.extern.slf4j.Slf4j;

/**
 * @author Zhouwx
 * @date 2025/7/1 14:50:18
 * @version 1.0
 * @description
 */
@Slf4j
@Service
public class MtoService extends BaseService {
    @Autowired
    private BaseTableConvertManager tableConvertManager;

    @Autowired
    private BaseDataTransferManager dataTransferManager;

    @Autowired
    private ResultPrintManager resultPrintManager;

    public String covertTables() {
        Context context = new Context();
        context.setTotalStartTime(System.currentTimeMillis());
        tableConvertManager.covertTables(context);
        context.setTotalEndTime(System.currentTimeMillis());
        resultPrintManager.writeResult(context);
        return "success";
    }

    public String fullConvert() {
        Context context = new Context();
        context.setTotalStartTime(System.currentTimeMillis());
        tableConvertManager.covertTables(context);
        dataTransferManager.transferData(context);
        context.setTotalEndTime(System.currentTimeMillis());
        resultPrintManager.writeResult(context);
        return "success";
    }

    public String transferData() {
        Context context = new Context();
        context.setTotalStartTime(System.currentTimeMillis());
        dataTransferManager.transferData(context);
        context.setTotalEndTime(System.currentTimeMillis());
        resultPrintManager.writeResult(context);
        return "success";
    }
}
